// pages/foodmaterialdetail/foodmaterialdetail.js
var foodmaterialsdata = require('../../data/foodmaterials_data.js'); 


Page({

  /**
   * 页面的初始数据
   */
  data: {
    foodUrl: "http://p06iwel4h.bkt.clouddn.com/dontstarve/foods/",
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var Name = options.Name;
    console.log(Name);
    var FoodMeats = foodmaterialsdata.foodmaterials.FoodMeats.Foods;
    var FoodVegetables = foodmaterialsdata.foodmaterials.FoodVegetables.Foods;
    var FoodFruit = foodmaterialsdata.foodmaterials.FoodFruit.Foods;
    var FoodEggs = foodmaterialsdata.foodmaterials.FoodEggs.Foods; 
    var FoodOthers = foodmaterialsdata.foodmaterials.FoodOthers.Foods;
    var types = [FoodMeats, FoodVegetables, FoodFruit, FoodEggs, FoodOthers];
    var item;
    for (var i = 0; i < types.length; i++) {
      for (var j = 0; j < types[i].length; j++) {
        if (types[i][j].Name == Name) {
          item = types[i][j];
          break;
        }
      }
    }
    
    this.setData({ item: item });
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {
  
  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
  
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {
  
  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {
  
  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
  
  },

  /**
   * 页面上拉触底事件的处理函数
   */
  onReachBottom: function () {
  
  },

  /**
   * 用户点击右上角分享
   */
  onShareAppMessage: function () {
  
  }
})